<template>
  <div id="app">
    <h1>{{ msg }}</h1>

    <el-input style="width: auto"
              placeholder="请输入桶名称"
              v-model="bucketName"
              clearable>
    </el-input>

    <p></p>
    <el-row>
      <el-button type="primary" @click="submit1()">创建桶 存在则抛异常</el-button>
    </el-row>

    <p>{{data}}</p>

  </div>
</template>

<script>


  var OSS = require("oss-js-client")

  // Instantiate the OSS client with the endpoint
  var ossClient = new OSS.Client({
    // endPoint: "192.168.1.40",
    endPoint: "127.0.0.1",
    port: 9000,
    useSSL: false,
    accessKey: "username",
    secretKey: "password",
  });

  export default {
    name: "VueOSS",
    data() {
      return {
        bucketName: 'mybucket3',
        data: '',
        msg: "演示OSSClient-连接验证",
      };
    },
    methods: {
      submit1: function () {
        //创建桶 存在则抛异常
        ossClient.makeBucket(this.bucketName, (err) => {
          if (err) {
            this.data = err;
            return console.log("Error creating bucket.", err);
          }

          this.data = "Bucket created successfully !";
          console.log('Bucket created successfully in "us-east-1".');
        });
      },

    }
  };
</script>

<style scope>
</style>
